<!--
Creator: Miroslav Milivojevic
-->

<div class="rate_choice">
    <table>
        <?php
        require_once dirname(__FILE__) . '/db.php';
        include_once dirname(__FILE__) . '/staticStars.php';
        $conn = dbConnect("sib");

        $IDHostel = $_GET["hid"];
        $numOfFbs_query = "SELECT COUNT(*) FROM feedback WHERE IDHostel = 10;"; //ovo promeniti !!!!
        $result = mysql_query($numOfFbs_query, $conn);
        $numOfFbs = mysql_fetch_array($result);
        $numOfFbs = $numOfFbs[0];
        ?>
        <?php
        $query = "SELECT AVG(Security) as Security,  AVG(Location) as Location, AVG(Service) as Service, AVG(Fun) as Fun," .
                "AVG(Cleanliness) as Cleanliness, AVG(Price) as Price " .
                "FROM feedback WHERE IDHostel = $IDHostel;"; //dinamicki
        $result = mysql_query($query, $conn);
//        if (!$result)
//            echo "Error:" . mysql_error();
        $row = mysql_fetch_array($result);
        ?>
        <tr>
            <td>Security: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Security"]));
                echo $ss_security->printStars($row['Security']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Location: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Location"]));
                echo $ss_security->printStars($row['Location']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Service: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Service"]));
                echo $ss_security->printStars($row['Service']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Fun: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Fun"]));
                echo $ss_security->printStars($row['Fun']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Cleanliness: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Cleanliness"]));
                echo $ss_security->printStars($row['Cleanliness']);
                ?>
            </td>
        </tr>
        <tr>
            <td>Price: </td>
            <td>
                <?php
                $ss_security = new staticStars(round($row["Price"]));
                echo $ss_security->printStars($row['Price']);
                ?>
            </td>
        </tr>
        
    </table>
</div>

<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>